﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using portfolio.Business;
using portfolio.Common;

namespace portfolio.Views
{
    public partial class Home : System.Web.UI.UserControl
    {
        private string LoadedAboutScreenControlName
        {
            get
            {
                return (string)ViewState[SessionConstants.LoadedAboutScreenControlName] ?? StringConstants.DefaultAboutScreenContentControl;
            }

            set
            {
                ViewState[SessionConstants.LoadedAboutScreenControlName] = value;
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            PopulateAboutWindowsSelection();
        }

        protected void rtvSkillSet_NodeClick(object sender, RadTreeNodeEventArgs e)
        {
            RadTreeNode node = e.Node;
            AboutScreenBL asBL = new AboutScreenBL();
            LoadedAboutScreenControlName = asBL.GetAboutScreenDataForValue(node.Value);
            PopulateAboutWindowsSelection();
        }

        protected void PopulateAboutWindowsSelection()
        {
            
            var control = LoadControl(StringConstants.AboutScreenViewsFolder + LoadedAboutScreenControlName);
            control.ID = StringConstants.GenericAboutControlID;
            AboutContent.Controls.Clear();
            AboutContent.Controls.Add(control);
        }
    }
}